package com.example.weatherapp233.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.example.weatherapp233.R;

import io.reactivex.rxjava3.annotations.NonNull;

public class GuidePagerAdapter extends RecyclerView.Adapter<GuidePagerAdapter.GuideViewHolder> {
    
    private Context context;
    private int[] guideImages = {R.drawable.guide01, R.drawable.guide02, R.drawable.guide03};
    private String[] guideTitles = {"欢迎使用天气应用", "查看实时天气", "获取生活建议"};
    private String[] guideDescriptions = {"一款简单实用的天气应用", "随时查看您所在位置的天气情况", "为您提供穿衣、运动等生活建议"};
    
    public GuidePagerAdapter(Context context) {
        this.context = context;
    }
    
    @NonNull
    @Override
    public GuideViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_guide, parent, false);
        return new GuideViewHolder(view);
    }
    
    @Override
    public void onBindViewHolder(@NonNull GuideViewHolder holder, int position) {
        holder.imageView.setImageResource(guideImages[position]);
        holder.titleView.setText(guideTitles[position]);
        holder.descView.setText(guideDescriptions[position]);
    }
    
    @Override
    public int getItemCount() {
        return guideImages.length;
    }
    
    static class GuideViewHolder extends RecyclerView.ViewHolder {
        ImageView imageView;
        TextView titleView;
        TextView descView;
        
        public GuideViewHolder(@NonNull View itemView) {
            super(itemView);
            imageView = itemView.findViewById(R.id.ivGuide);
            titleView = itemView.findViewById(R.id.tvTitle);
            descView = itemView.findViewById(R.id.tvDesc);
        }
    }
}